package sfeir.gwt.ergosoom.client;

import sfeir.gwt.ergosoom.client.faq.FaqStackPanel;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.Dictionary;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.EventListener;
import com.google.gwt.user.client.ui.RootPanel;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class ErgoSoom implements EntryPoint {

    /**
     * This is the entry point method.
     */
    public void onModuleLoad() {
        // if (GWT.getModuleName().equals("editprofile")) {
        // Element elt = DOM.getElementById("import");
        // DOM.setStyleAttribute(elt, "display", "block");
        // DOM.setEventListener(elt, new EventListener() {
        // @Override
        // public void onBrowserEvent(Event event) {
        //                    
        // if (Event.ONCLICK == event.getTypeInt())
        // new ImportDialog().center();
        // }
        // });
        // DOM.sinkEvents(elt, Event.ONCLICK);
        // }
        // Medias images = GWT.create(Medias.class);
        // Image im = (Image) images.scergo().createImage();
        //        
        // RootPanel.get("content").add(im);

        // PushButton logger = new PushButton("Log In");
        // logger.setHTML("<a href='#' class='logger'><h1>Log in</h1></a>");
        // logger.setPixelSize(100, 50);
        // logger.setStyleName("logger");
        //        
        // logger.addClickHandler(new ClickHandler(){
        //
        // @Override
        // public void onClick(ClickEvent event) {
        //                
        // LoginDialog log = new LoginDialog();
        //
        // RootPanel.get("login_button").clear();
        // RootPanel.get("login_button").add(log);
        // }
        //            
        // });
        // RootPanel.get("login_button").add(logger);
        String email = null;
        try {
            email = Dictionary.getDictionary("Credentials").get("login");
        } catch (Exception e) {
        }
        RootPanel.get("logout").setVisible((email != null));        
    }

    // redirige le browser sur l'url donnée
    public static native void redirect(String url)/*-{
                                                  $wnd.location = url;
                                                  }-*/;
}
